package com.wjy.icu.controller;

import com.wjy.icu.common.annotation.PassToken;
import com.wjy.icu.common.core.domain.R;
import com.wjy.icu.domain.Icuuser;
import com.wjy.icu.domain.vo.MemberDto;
import com.wjy.icu.domain.vo.UserDto;
import com.wjy.icu.service.IUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Description:
 * @author: wangjunyong
 * @date: 2021/10/26 11:29
 */
@RestController
@RequestMapping("business/user")
public class UserController {

    @Autowired
    private IUserService userService;

    /**
     * 新增保存用户信息
     */
    @PassToken
    @PostMapping("register")
    public R addSave(@RequestBody UserDto user) {
        return R.data(userService.register(user));
    }

    @PassToken
    @GetMapping("grouplListEquip")
    public R grouplListEquip(@RequestParam Integer userId) {
        return R.data(userService.grouplListEquip(userId));
    }

    @PassToken
    @GetMapping("grouplListUser")
    public R grouplListUser(@RequestParam Integer userId) {
        return R.data(userService.grouplListUser(userId));
    }
    @PassToken
    @PostMapping("addGroupMember")
    public R addGroupMember(@RequestBody MemberDto memberDto) {
        userService.addGroupMember(memberDto);
        return R.ok();
    }

    @PassToken
    @PostMapping("deleteGroupMember")
    public R deleteGroupMember(@RequestBody MemberDto memberDto) {
        userService.deleteGroupMember(memberDto);
        return R.ok();
    }

}
